package com.Yourweibo;

 

import java.io.Serializable;
import java.util.List;

import weibo4android.Paging;
import weibo4android.Status;
import weibo4android.Weibo;
import weibo4android.WeiboException;
import android.app.ActivityGroup;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.Yourweibo.status.TimeLineConstant;

public class mainActivity extends ActivityGroup {
	private LinearLayout freamworks;
	private Weibo weibo;
	private Context context;
	private Intent intent;
	private Thread Loading;
	private ProgressBar progressbar;
	  Handler handler=new Handler(){

		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			super.handleMessage(msg);
			switch(msg.arg1){
			case 1:
				freamworks.addView(getLocalActivityManager().startActivity(
						"M1",intent).getDecorView());
				progressbar.setVisibility(View.GONE);
				break;
			
			}
			
		}
		  
		  
		  
	  };
	  public void loadFriendTimeline(){
		  Loading=new Thread(){

				@Override
				public void run() {
					// TODO Auto-generated method stub
					super.run();

					 List<Status> FriendsTimelineList = null;
					 Paging pagin=new Paging();
					 pagin.setPage(1);
				 
					 try {
						FriendsTimelineList=weibo.getFriendsTimeline(pagin);
					} catch (WeiboException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					 //获得微博的count   
					
					 intent=new Intent(mainActivity.this, FriendTimelineActivity.class);
					 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
					 intent.putExtra("Timeline",(Serializable)FriendsTimelineList);
					 Message message=handler.obtainMessage();
					 message.arg1=1;
					 handler.sendMessage(message);
						
				
				}
				 
				 
				 
			 }; 
				Loading.start();
		  
	  }
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.framework);
		context=this.getApplicationContext();
		weibo=TimeLineConstant.getInstance().getWeibo();
		freamworks=(LinearLayout)this.findViewById(R.id.main_framework);
		progressbar=(ProgressBar)this.findViewById(R.id.main_progressbar);
		loadFriendTimeline();
	
		 
	}
	 
	
	

}
